home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_10.lha / 7_10 / p_runtask.c < prev    next >
C/C++ Source or Header  |  1993-08-08  |  2KB  |  54 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <process.h>
  6. include <debug.h>    /* DELETE */
  7. / Run the given process
  8. oid process::exec()
  9.  
  10.    if (debug) /*DELETE*/ cerr << "process" << this << "::exec()\n";
  11.    char x;
  12.    char *px = &x;
  13.  
  14.    if (t_stackbase == 0)
  15. {
  16. if (debug)    /*DELETE*/ cerr << "---- setting t_stackbase <- ";
  17. if (debug>1)    /*DELETE*/ cerr << form("%#x", &x);
  18. if (debug)     /*DELETE*/ cerr << "\n";
  19. t_stackbase = px;
  20. }
  21.    if (debug)  /*DELETE*/ cerr << "t_stackbase == ";
  22.    if (debug>1)/*DELETE*/ cerr << form("%#x", t_stackbase);
  23.    if (debug)  /*DELETE*/ cerr << "\n";
  24.    if (debug)  /*DELETE*/ cerr << "st::plusone == ";
  25.    if (debug>1)/*DELETE*/ cerr << form("%#x", Stackdir.plusone());
  26.    if (debug)  /*DELETE*/ cerr << "\n";
  27.    if (debug)  /*DELETE*/ cerr << "st::diff    == " << Stackdir.diff(t_stackbase, Stackdir.plusone()) << "\n";
  28.  
  29.    if (Stackdir.less(px, t_stackbase))
  30.        exec();
  31.  
  32.    else
  33. {
  34. // parent <- thisprocess
  35. // set the parent as runnable
  36. process *parent = t_thisprocess;
  37. if (debug) /*DELETE*/ cerr << "\tparent == " << parent << "\n";
  38. parent->t_next = t_runprocesses;
  39. t_runprocesses = parent;
  40. parent->t_curstate = TASK_RUNNABLE;
  41. if (debug) /*DELETE*/ cerr << "\t" << parent << "->t_curstate <- " << ps_print(parent->t_curstate) << "\n";
  42.  
  43. if (!parent->contextswitch())
  44.     {        // in child
  45.     // child <- thisprocess
  46.     t_thisprocess = this;
  47.     t_curstate = TASK_RUNNABLE;
  48.     if (debug) /*DELETE*/ cerr << "\t" << this << "->t_curstate <- " << ps_print(t_curstate) << "\n";
  49.     exit(main());
  50.     }
  51. }
  52.    if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::exec()\n";
  53.  
  54.